@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">
        <?php /*?>
        <button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>
        <div class="search_box">
            
            <form id="search_form" method="GET">
                <label>
                    标题：<br>
                    <input name="key" type="text" class="form-control search_form_control" value="{{ $_search['key'] }}">
                </label>
                <label>
                    分类：<br>
                    <select name="type" class="form-control search_form_control">
                        <option value="">全部</option>
                        @foreach($cats as $cat_id=>$item)
                        <option value="{{$cat_id}}" @if($_search['type']==$cat_id) selected="" @endif>{{$item->name}}</option>
                        @endforeach
                    </select>
                </label>
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>
            <?php */?>
        </div>

        <div class="table-responsive">
            <table class="table">
                <caption>排队上线中文章({{$list->total()}})</caption>
                <thead>
                    <tr>
                        <th>#</th>
                        <th>article ID</th>
                        <th>图片</th>
                        <th>标题</th>
                        <th>分类</th>
                      
                        <th>审核时间</th>
                        
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr id="tr_{{$item->id}}">
                            <td>{{ $item->id }}</td>
                            <td>{{ $item->article_id }}</td>
                            <td>
                                @foreach($item->pic as $img)
                                    <img style="max-width:80px" src="{{$img}}" />
                                @endforeach

                            </td>
                            <td><a href="javascript:;" onclick="layx.iframe('{{$item->article_id}}','{{$item->title}}','/article/info/{{$item->article_id}}',{
    statusBar:true
});" > {{ $item->title }}</a></td>
                            <td id="cat_{{$item->id}}">{{ $item->cat_name }}</td>
                            
                            <td>{{ date('Y-m-d H:i:s',$item->add_time) }}</td>
                            <td>
                                {{$item->username}}
                                <!--<a href="http://www.{{ env('APP_URL') }}/home/article/{{ $item->id }}" target="_blank">查看</a>
                                <a href="/Theme/edit/{{ $item->id }}">编辑</a>-->
                                <a href="javascript:;" onclick="ajax_delete_theme(<?=$item->id?>)">删除</a>
                                
                            </td>
                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="7">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
                {{ $list->links() }}
            </div>
        </div>

    </div>
@endsection

@section('foot')
<script type="text/javascript">
$.ajaxSetup({
    headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
})

function ajax_delete_theme(id){
    if(confirm('确认删除吗?')){
        $.post("/article/ajax_delete_queue/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
function set_cat(id,obj){
    var type = $(obj).val();
    var name = $(obj).find("option:selected").text();
    $("td#cat_"+id).text(name);
    $.post('/article/ajax_set_cat/'+id,{type:type},function(json){
    
    },"json");
}
</script>
@endsection